package com.example.indenture.message.controller;

import com.example.indenture.common.vo.Result;
import com.example.indenture.message.entity.Message;
import com.example.indenture.message.service.MessageService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api")
public class MessageController {
    @Autowired
    private MessageService messageService;


    @PostMapping(value = "/message/insert", consumes = MediaType.APPLICATION_JSON_VALUE)
    public Result<Message> insertUser(@RequestBody Message meaasge) {
        return messageService.insertMessage(meaasge);
    }
    @Data
    static class MessageData {
        Message message;
        List<Message> messageList;
    }

    @PostMapping(value = "/messages", consumes = MediaType.APPLICATION_JSON_VALUE)
    public List<List<Message>> getTeamsBySearch(@RequestParam("rid") Integer rid) {
        return messageService.selectMessage(rid);
    }

}
